package com.marvels.approve.manager.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.marvels.approve.manager.dao.ICaseManagerDao;
import com.marvels.approve.manager.dao.ICaseManagerVersionDao;
import com.marvels.approve.manager.dto.CaseManagerDTO;
import com.marvels.approve.manager.dto.CaseManagerVersionDTO;
import com.marvels.approve.manager.service.ICaseManagerService;
import com.marvels.common.exception.MarvelsBusinessException;
@Service
public class CaseManagerServiceImpl implements ICaseManagerService {
	@Autowired
	private ICaseManagerDao caseManagerDao;
	@Autowired
	private ICaseManagerVersionDao caseManagerVersionDao;
	@Override
	public CaseManagerDTO findCaseManager(Long id) throws MarvelsBusinessException {
		if(id == null){
			throw new MarvelsBusinessException("输入不能为空");
		}
		CaseManagerDTO caseManager = this.caseManagerDao.selectByPrimaryKey(id);
		return caseManager;
	}

	@Override
	public List<CaseManagerDTO> findCaseManager(CaseManagerDTO caseManagerDto) throws MarvelsBusinessException {
		// TODO 自动生成的方法存根
		List<CaseManagerDTO> cms;
		try {
			PageHelper.startPage(caseManagerDto.getPageNo(), caseManagerDto.getPageSize());
			cms = caseManagerDao.select(caseManagerDto);
			return cms;
		} catch (Exception e) {
			throw new MarvelsBusinessException(e);
		}
	} 
	
	@Override
	public List<CaseManagerVersionDTO> findProcessVersions(CaseManagerVersionDTO caseManagerVersionDto)
			throws MarvelsBusinessException {
		// TODO 自动生成的方法存根
		try {
			PageHelper.startPage(caseManagerVersionDto.getPageNo(), caseManagerVersionDto.getPageSize());
			List<CaseManagerVersionDTO> datas = caseManagerVersionDao.select(caseManagerVersionDto);
			return datas;
		} catch (Exception e) {
			throw new MarvelsBusinessException(e);
		}
	}
	
 
}
